<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 

  <head>
    <base target="_self"/>  
    <title>表单信息修改页面</title>
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <link rel="stylesheet" type="text/css" href="<%=path %>/web/style/layout.css" />
    <script type="text/javascript" src="<%=path %>/jqGrid/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<%=path %>/jslib/jquery.validate.min.js"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/jquery.form.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/additional-methods.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/demo.css">
	<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
    <c:if test="${requestScope.message!=null}">
				<script type="text/javascript">
	  	 		     alert('<c:out value="${requestScope.message}"></c:out>');
	  	 		     window.close();	  	 		 
	  			</script>
	        </c:if>
    <script type="text/javascript">
    var api = frameElement.api, W = api.opener;
    $().ready(function() {
        specialType2();
	$("#pageFrom").validate({
		onkeyup :false,onclick:false,
			rules: {
				fromColumn:{
					required:true,
					number:true
				}
			},
		messages: {
			fromColumn:{
				required:"表单列数不能为空",
				number:"表单列数只能为数字"
			}
		},  
	   /* 重写错误显示消息方法,以alert方式弹出错误消息 */  
	   showErrors : function(errorMap, errorList) {
		    var msg = "";  
		    $.each(errorList, function(i, v) {  
		     msg = (v.message + "\r\n");  
		    
		    if (msg != ""){  
		     alert(msg);
		     return false;  
		     }
		     });  
		   onfocusout=false; 
	   }
	  });  
	  
	var options = {
  	    url:'updateAutoFormById.action',
  	     beforeSubmit:checkForm,
  	    dataType:'json',
  	    success: function(data) {
  	      if(data.result=='success'){
			alert("修改成功");
			api.close();
			W.gridSearch();
  	      }else{
  	      	alert("系统繁忙，请您稍后再试！");
  	      	api.close();
			W.gridSearch();
  	      }
  	    }};
		$('#saveBtn').click(function(){
			    	$('#pageFrom').ajaxSubmit(options);
	 	            return false;
    	 });
		$('#closeBtn').click(function(){
			api.close();
    	 });
    	 
});
 //表单验证
   function checkForm()
    {
      var returnValue =  $('#pageFrom').form('enableValidation').form('validate');
      if(!returnValue){
        return false;
      }
      
      if($("#formColumn").val()==''){
	         alert("请填写表单列数!");
			 $("#formColumn").focus();
			 return false;
	        
	  }else{
	      if($("#formColumn").val()!=''){
	         if (!(/(^[1-9]\d*$)/.test($("#formColumn").val()))) {
	            alert("表单列数必须为正整数!");
			    $("#formColumn").focus();
			    return false;
		     }else if($.trim($("#formColumn").val())>2){
			    alert("表单列数不能大于2");
			    $("#formColumn").focus();
			    return false;
		     } 
	        }
	   }
     }
	function selectformtype(){
		var k = window.showModalDialog('autoFromsAction!getDicselectviewinfo.action?id=321',null,"dialogWidth=850px;dialogHeight=430px;resizable=yes");
		if (k==undefined)
		{
			k = '';
		}
		document.getElementById("suoslx").value = k;
	}
	function specialType1(){
		if($("#specialColumn").val()==3 || document.getElementById("specialColumn").value==4 ){
		
			document.getElementById("r1").style.display="";
			document.getElementById("r2").style.display="";
		}else{
			document.getElementById("r1").style.display="none";
			document.getElementById("r2").style.display="none";
		}
	}
	function countlen(textarea){
	    if (textarea.value.length> 250){
	        alert("最多为250个字符,字符输入超出限制!");
	        textarea.value=textarea.value.substring(0,250);
	    }
	    return true;
	}
	function specialType(){
		if(${af.specialColumn =='3' } || ${af.specialColumn =='4' } ){
		
			document.getElementById("r1").style.display="";
			document.getElementById("r2").style.display="";
		}else{
			document.getElementById("r1").style.display="none";
			document.getElementById("r2").style.display="none";
		}
	}
	function specialType2(){
		if(document.getElementById("specialColumn").value!=''&&document.getElementById("specialColumn").value!=2){
		
			document.getElementById("r1").style.display="";
			document.getElementById("r2").style.display="";
		}else{
			document.getElementById("r1").style.display="none";
			document.getElementById("r2").style.display="none";
		}
	}
	
	function selectfield(source){
		var fieldname=source.id;
		//var fieldname = window.showModalDialog('<%=request.getContextPath() %>/form/auto_form_field_list_select.jsp?formId=${af.id}&formTableName=${af.formEnName}',null,'dialogWidth=1050px;dialogHeight=650px;resizable=yes;scroll=yes');
		var url='<%=request.getContextPath() %>/form/auto_form_field_list_select.jsp?fieldname='+fieldname+'&formId=${af.id}&formTableName=${af.formEnName}';
		var height = 500;
		var width = 500;
		var top=Math.round((window.screen.height-height)/2);
		var left=Math.round((window.screen.width-width)/2);
	    window.open(url,"","width="+width+",height="+height+",top="+top+",left="+left);
		/*if (fieldname!=undefined){
			source.value = fieldname;
		}*/
	}
	
	function marktypechange(source){
		if (source.value=="0"){
			document.getElementById("endpoints").style.display = "none";
		}
		else{
			document.getElementById("endpoints").style.display = "";
		}
	}
   </script>
  			 
	<style type="text/css">
 		body{
 			background:#ffffff; background-image:url(images/);
 		}
   </style>
  </head> 
  <body>
    <form action="" id="pageFrom" name="" method="post" class="easyui-form" data-options="novalidate:true">
    <input type="hidden" id="formId" name="formId" value="${af.id}"/>
    	<table width="100%" border="0" align="center" cellpadding="5" cellspacing="5" class="formTableNew">
		   <tr>
		    <td align="right" width="11%">表单中文名称：</td>
		    <td align="left">
				<input type="text" id="formCnName" name="formCnName" value="${af.formCnName }" disabled="disabled" style="border: 1px solid #999;padding: 5px;width: 250px;"/>
				<img src="<%=request.getContextPath() %>/images/xh.png"></img>
		    </td>
		    <td align="right" width="11%">表单英文名称：</td>
		    <td align="left">
				<input type="text" id="formEnName" name="formEnName" value="${af.formEnName }" disabled="disabled" style="border: 1px solid #999;padding: 5px;width: 250px;"/>
				<img src="<%=request.getContextPath() %>/images/xh.png"></img>
		    </td>
		  </tr>
		  <tr>
		    <td align="right">表单宽：</td>
		    <td> 
				<input class='easyui-numberbox' type="text" id="formwidth" name="formwidth" value="${af.formwidth }" style="border: 1px solid #999;padding: 5px;width: 250px;"/>
		    </td>
		    <td align="right">表单高：</td>
		    <td> 
				<input class='easyui-numberbox' type="text" id="formheight" name="formheight" value="${af.formheight }" style="border: 1px solid #999;padding: 5px;width: 250px;"/>
		    </td>
		  </tr>
		  <tr>
		    <td align="right">表单列数：</td>
		    <td> 
				<input type="text" id="formColumn" name="formColumn" value="${af.formColumn }" style="border: 1px solid #999;padding: 5px;width: 250px;"/>
				<img src="<%=request.getContextPath() %>/images/xh.png"></img>
		    </td>
		    <td align="right">外键：</td>
			    <td >
			    <input type="text" id="columnForigen" name="columnForigen" maxlength="25" value="${af.columnForigen }" style="border: 1px solid #999;padding: 5px;width: 250px;"/>
			    </td>
			</tr>
		  <tr> 
			    <td align="right">列表中文信息：</td>
			    <td >
			    <textarea rows="5" cols="30" id="columnCnName" name="columnCnName" onkeydown="countlen(this);" style="border: 1px solid #999;padding: 5px;width: 250px;">${af.columnCnName }</textarea>
			    </td>
			    <td align="right">SQL语句：</td>
			    <td >
			     <textarea rows="5" cols="30" id="columnSql" name="columnSql" onkeydown="countlen(this);" style="border: 1px solid #999;padding: 5px;width: 250px;">${af.columnSql }</textarea>
			    </td>
			</tr>
		  <tr> 
		    <td align="right">列表字段宽度：</td>
		    <td>
		    <textarea rows="5" cols="30" id="columnWidth" name="columnWidth" onkeydown="countlen(this);" style="border: 1px solid #999;padding: 5px;width: 250px;">${af.columnWidth }</textarea>
		    </td>
		    <td align="right">其他sql：</td>
			    <td >
			    	<textarea rows="5" cols="30" id="otherColumnSql" name="otherColumnSql" onkeydown="countlen(this);" style="border: 1px solid #999;padding: 5px;width: 250px;">${af.otherColumnSql }</textarea>
			    </td>
			</tr>
		<tr>
			<td align="right">列表过滤条件sql：</td>
		    <td >
		    	<textarea rows="5" cols="30" id="columnguolvsql" name="columnguolvsql" onkeydown="countlen(this);" style="border: 1px solid #999;padding: 5px;width: 250px;">${af.columnguolvsql } </textarea>
		    </td>
		     <td align="right">显示信息：</td>
			<td >
			    <select id="specialColumn"  name="specialColumn" onchange="specialType2();" style="border: 1px solid #999;padding: 5px;width: 260px;">
			    	<option value=""></option>
			    	<option <c:if test="${af.specialColumn =='1' }">selected</c:if> value="1">样品/检测项目分配</option>
			    	<option <c:if test="${af.specialColumn =='2' }">selected</c:if>  value="2">人员分配</option>
			    	<option <c:if test="${af.specialColumn =='3' }">selected</c:if>  value="3">原始记录分配</option>
			    	<option <c:if test="${af.specialColumn =='4' }">selected</c:if>  value="4">报告分配</option>
			    	<option <c:if test="${af.specialColumn =='5' }">selected</c:if>  value="5">样品/检测项目列表</option>
			    </select>
			</td>
			</tr>
		  <tr> 
		   
			<td id="r1" >操作类型：</td>
			<td id="r2" colspan="3">
			    <select name="specialType" style="border: 1px solid #999;padding: 5px;width: 260px;">
			    	<option <c:if test="${af.specialType =='1' }">selected</c:if> value="1" >编辑</option>
			    	<option <c:if test="${af.specialType =='2' }">selected</c:if> value="2" >查看</option>
			    </select>
			</td>
		  </tr>
		   <tr >
		  	<td align="right">是否显示地图：</td>
		    <td align="left"  >
		    	<select name="isshowmap" style="border: 1px solid #999;padding: 5px;width: 260px;">
			    	<option <c:if test="${af.isshowmap =='0' }">selected</c:if> value="0" >否</option>
			    	<option <c:if test="${af.isshowmap =='1' }">selected</c:if> value="1" >是</option>
			    </select>
		    </td>
		    <td align="right">地图显示字段：</td>
		    <td align="left"  >
		    	<input type="text" id="mapmark" name="mapmark" value="${af.mapmark }" readonly=true onfocus="selectfield(this)"  style="border: 1px solid #999;padding: 5px;width: 250px;"/>
		    </td>
		  </tr>
		  <tr>
		  	<td align="right">显示类型：</td>
		    <td align="left"  colspan="3" >
		    	<select name="marktype" style="border: 1px solid #999;padding: 5px;width: 260px;" onchange="marktypechange(this);">
			    	<option <c:if test="${af.marktype =='0' }">selected</c:if> value="0" >点</option>
			    	<option <c:if test="${af.marktype =='1' }">selected</c:if> value="1" >线段</option>
			    </select>
		    </td>
		  </tr>
		  <tr >
		  	<td align="right">经度字段：</td>
		    <td align="left"  >
		    	<input type="text" id="bjingdu" name="bjingdu" value="${af.bjingdu }" readonly=true onclick="selectfield(this)"  style="border: 1px solid #999;padding: 5px;width: 250px;"/>
		    </td>
		    <td align="right">纬度字段：</td>
		    <td align="left"  >
		    	<input type="text" id="bweidu" name="bweidu" value="${af.bweidu }" readonly=true onclick="selectfield(this)"  style="border: 1px solid #999;padding: 5px;width: 250px;"/>
		    </td>
		  </tr>
		  <tr id='endpoints' style='<c:if test="${af.marktype =='0' }">display:none;</c:if>'>
		  	<td align="right">经度字段（结束）：</td>
		    <td align="left"  >
		    	<input type="text" id="ejingdu" name="ejingdu" value="${af.ejingdu }" readonly=true onclick="selectfield(this)"  style="border: 1px solid #999;padding: 5px;width: 250px;"/>
		    </td>
		    <td align="right">纬度字段（结束）：</td>
		    <td align="left"  >
		    	<input type="text" id="eweidu" name="eweidu" value="${af.eweidu }" readonly=true onclick="selectfield(this)"  style="border: 1px solid #999;padding: 5px;width: 250px;"/>
		    </td>
		  </tr>
		  <tr >
		  	<td align="right">表单说明：</td>
		    <td align="left" colspan="3" >
		    <div class="div">
				<textarea rows="5" cols="87" id="formNote" name="formNote" onkeydown="countlen(this);" style="border: 1px solid #999;padding: 5px;width: 700px;">${af.formNote }</textarea>
			</div>
		    </td>
		  
		  </tr>
		  <tr>
		    <td align="center" colspan="4" >
		    	<input type="button" id="saveBtn" value="提 交" class="form_bt_orange" />
		      	<input type="button" id="closeBtn" value="取 消" class="form_bt_grey" />
		    </td>
		  </tr>
		</table>
	</form>
  </body>
</html>
